/**
 * 
 */
package libcommonuse11.clonedemo;

/**
 * @author liuzq
 *
 */

class Person implements Cloneable
{
	private String name;
	private int age;
	
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public int getAge()
	{
		return age;
	}
	public void setAge(int age)
	{
		this.age = age;
	}
	@Override
	public String toString()
	{
		return "姓名："+this.name+",年龄："+this.age;
		
	}
	public  Object clone()
    throws CloneNotSupportedException
    {
		return super.clone();
    }
	
}
public class CloneDemo01
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Person  per1 = new Person();
		Person per2 = null;
		per1.setAge(30);
		per1.setName("刘兆清");
		try
		{
			per2 = (Person)per1.clone();
		}
		catch(CloneNotSupportedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println(per2);
		System.out.println(per2 == per1);
	}

}
